import 'package:flutter/material.dart';

import 'shape.dart';

/// 三角
class DxTriangleShape extends Shape {
  final double percentBottom;
  final double percentLeft;
  final double percentRight;

  DxTriangleShape({this.percentBottom = 0.5, this.percentLeft = 0, this.percentRight = 0});

  @override
  Path build({Rect? rect, double? scale}) => generatePath(rect: rect!);

  Path generatePath({bool? useBezier, required Rect rect}) {
    final width = rect.width;
    final height = rect.height;
    return Path()
      ..moveTo(0, percentLeft * height)
      ..lineTo(percentBottom * width, height)
      ..lineTo(width, percentRight * height)
      ..close();
  }
}
